package com.hyz.controller;

import com.hyz.model.dto.ApprovalResultRequest;
import com.hyz.model.vo.AssetMaintenanceResponse;
import com.hyz.model.vo.AssetRetirementResponse;
import com.hyz.model.vo.AssetSecondmentResponse;
import com.hyz.service.permission.OperationsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.ResponseResult;

import java.util.List;

/**
 * @author HGD
 * @date 2022/10/10 15:43
 */

@Api("运维人员")
@RestController
@RequestMapping("/operations")
@PreAuthorize("hasAnyAuthority('rights','operations')")
public class OperationsController {
    @Autowired
    private OperationsService service;

    @ApiOperation("运维人员审批资产借调申请")
    @PostMapping("/opGetAssetSecondments")
    public ResponseResult<List<AssetSecondmentResponse>> opGetAssetSecondments() {
        return service.opGetAssetSecondments();
    }

    @ApiOperation("运维人员审批资产借调申请")
    @PostMapping("/opUpdateAssetSecondments")
    public ResponseResult<List<AssetSecondmentResponse>> opUpdateAssetSecondments(@RequestBody ApprovalResultRequest request) {
        return service.opUpdateAssetSecondments(request);
    }

    //---------------------------------------------------------------------------------------------------------
    // 资产维修

    @ApiOperation("运维人员获取维修申请")
    @PostMapping("opGetAssetMaintenance")
    public ResponseResult<List<AssetMaintenanceResponse>> opGetAssetMaintenance() {
        return service.opGetAssetMaintenance();
    }

    @ApiOperation("运维人员审批维修申请")
    @PostMapping("opUpdateAssetMaintenance")
    public ResponseResult<List<AssetMaintenanceResponse>> opUpdateAssetMaintenance(@RequestBody ApprovalResultRequest request) {
        return service.opUpdateAssetMaintenance(request);
    }

    //---------------------------------------------------------------------------------------------------------
    // 资产报废

    @ApiOperation("运维人员获取报废申请")
    @PostMapping("/opGetAssetRetirement")
    public ResponseResult<List<AssetRetirementResponse>> opGetAssetRetirement() {
        return service.opGetAssetRetirement();
    }

    @ApiOperation("运维人员审批报废申请")
    @PostMapping("/opUpdateAssetRetirement")
    public ResponseResult<List<AssetRetirementResponse>> opUpdateAssetRetirement(@RequestBody ApprovalResultRequest request) {
        return service.opUpdateAssetRetirement(request);
    }
}
